#ifndef RAW_LIST_H
#define RAW_LIST_H
/*
 * Doubly-link list
 */
typedef struct LIST {
	struct LIST	*next;
	struct LIST	*previous;
} LIST;


#define list_entry(node, type, member)    ((type *)((RAW_U8 *)(node) - (RAW_U32)(&((type *)0)->member)))


///*
// * List initialization
// */
//#define list_init(list_head)	\
//					do {\
//						(list_head)->next = (list_head);\
//						(list_head)->previous = (list_head);\
//					 } while (0)


///*
// * return TRUE if the list is empty
// */
//#define is_list_empty(list)   return ((list)->next == (list))


//					

///*
// * add element to list
// * add element before head.
// */
//#define list_insert(head, element)    \
//					do {\
//						(element)->previous = (head)->previous;\
//						(element)->next = (head);\
//						(head)->previous->next = (element);\
//						(head)->previous = (element);\
//					 } while (0)


///*
// * delete element to list
// */					
//#define list_delete(element)          \
//				do {\
//					(element)->previous->next = (element)->next;\
//					(element)->next->previous = (element)->previous;\
//				} while (0)

#define RAW_INLINE  		static __inline
typedef  unsigned  char       RAW_BOOLEAN;               /*  8-bit boolean or logical */
    
/*
 * List initialization
 */
RAW_INLINE void list_init(LIST *list_head)
{
	list_head->next = list_head;
	list_head->previous = list_head;
}

/*
 * return TRUE if the list is empty
 */
RAW_INLINE RAW_BOOLEAN is_list_empty(LIST *list)
{

	return (list->next == list);	
	
}

/*
 * add element to list
 * add element before head.
 */
RAW_INLINE void list_insert(LIST *head, LIST *element)
{
	
	element->previous = head->previous;
	element->next = head;
	
	head->previous->next = element;	
	head->previous = element;
}


RAW_INLINE void list_delete(LIST *element)
{

	element->previous->next = element->next;
	element->next->previous = element->previous;
	
}


#endif

